﻿namespace TrinityEngine
{
    public class Color
    {
        private Microsoft.Xna.Framework.Color _color;

        public float r => _color.R / 255;

        public float g => _color.G / 255;

        public float b => _color.B / 255;

        public float a => _color.A / 255;

        public Color(float r, float g, float b, float a = 1f)
        {
            _color = new Microsoft.Xna.Framework.Color(r, g, b, a);
        }

        public Color(uint color)
        {
            _color = new Microsoft.Xna.Framework.Color(color);
        }

        public Color(Microsoft.Xna.Framework.Color color)
        {
            _color = color;
        }

        public static Color White = new Color(1f, 1f, 1f, 1f);

        public static Color Black = new Color(0f, 0f, 0f, 0f);

        public override string ToString()
        {
            return $"Color({r}, {g}, {b}, {a})";
        }

        public static implicit operator Microsoft.Xna.Framework.Color(Color color)
        {
            return color._color;
        }

        public static implicit operator Color(Microsoft.Xna.Framework.Color color)
        {
            return new Color(color);
        }

        public static implicit operator System.Drawing.Color(Color color)
        {
            return System.Drawing.Color.FromArgb(color._color.A, color._color.R, color._color.G, color._color.B);
        }
    }
}
